package com.animee.day15.provider;

import ohos.aafwk.ability.AbilitySlice;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.PageSliderProvider;

import java.util.List;

public class TabPageProvider extends PageSliderProvider{
    AbilitySlice context;
    List<Component>list;
    public TabPageProvider(AbilitySlice context, List<Component> list) {
        this.context = context;
        this.list = list;
    }
    @Override    //返回滚动的页数
    public int getCount() {return list.size();}
    @Override
    public Object createPageInContainer(ComponentContainer componentContainer, int i) {
        Component component = list.get(i);
        componentContainer.addComponent(component);
        return component;
    }
    @Override
    public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) {
        Component component = list.get(i);
        componentContainer.removeComponent(component);
    }
    @Override
    public boolean isPageMatchToObject(Component component, Object o) {
        return component == o;
    }
}